<?php  
class ControllerModulehotrotructuyen extends Controller {
	protected function index() {
		$this->language->load('module/hotrotructuyen');

      	$this->data['heading_title'] = $this->language->get('heading_title');
		
		$this->data['code'] = html_entity_decode($this->config->get('hotrotructuyen_code_'. $this->config->get('config_language_id')), ENT_QUOTES, 'UTF-8');
		
		$this->load->model('catalog/hotrotructuyen');
		$this->load->model('catalog/danhmuchotro');
		$this->data['danhmuchotros'] = array();
		$hotrotructuyens = array();
		$total = 0;
		foreach ($this->model_catalog_danhmuchotro->getdanhmuchotros() as $danhmuchotro_info) {
			$hotrotructuyens[$danhmuchotro_info['danhmuchotro_id']] = array();
			foreach ($this->model_catalog_hotrotructuyen->gethotrotructuyenbydanhmuchotro($danhmuchotro_info['danhmuchotro_id']) as $result) {
				$hotrotructuyens[$danhmuchotro_info['danhmuchotro_id']][] = array(
					'title' => $result['title'],
					'nickyahoo' => $result['nickyahoo'],
					'nickskype' => $result['nickskype'],
					'sodienthoai' => $result['sodienthoai']
				);
				$total++;
			}
			$this->data['danhmuchotros'][] = array(
				'name' => $danhmuchotro_info['name'],
				'hotrotructuyens' => $hotrotructuyens[$danhmuchotro_info['danhmuchotro_id']]
			);
		}
		//total support 
		$this->data['total'] = $total;

		//echo "<pre>";print_r($this->data['danhmuchotros']);die();
		
		$this->id = 'hotrotructuyen';

		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/hotrotructuyen.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/hotrotructuyen.tpl';
		} else {
			$this->template = 'default/template/module/hotrotructuyen.tpl';
		}
		
		$this->render();
	}
}
?>